const app = getApp();
Page({


  data: {
    messageId: null
  },

  onLoad: function (options) {
    this.setData({
      messageId: options.messageId
    });
  },

  onReady: function () {

  },


  formsubmit: function (e) {
    let _this = this;
    wx.request({
      url: 'https://dorm.dormassistant.wang:8080/comment/addComment',
      data: {
        userId: app.globalData.userId,
        messageId :this.data.messageId,
        text: e.detail.value.text
      },
      method: "POST",
      header: {
        'Content-Type': 'application/x-www-form-urlencoded;charset=utf8'
      },
      success: function (res) {
        if (res.data.success) {
          wx.navigateBack({
            url: "../socialContactDetail/socialContactDetail?messageId=" + _this.data.messageId
          });
        } else {
          var toastText = '提交失败' + res.data.errMsg;
          wx.showToast({
            title: toastText,
            icon: '',
            duration: 2000
          });
        }
      },
      fail: function (res) {
        var toastText = '提交失败' + res.data.errMsg;
        wx.showToast({
          title: toastText,
          icon: '',
          duration: 2000
        });
      }
    });

  }


})